package UI;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import service.AccountServiceImpl;
import service.IAccountService;

public class Ui_Test {

    public static void main(String[] args) {
        /*
        第一种常用，要使用项目的相对路径(默认构造函数创建自己的对象)
        * */
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("Bean.xml");
//        ApplicationContext applicationContext=new FileSystemXmlApplicationContext("C:\\Users\\长安\\Desktop\\Bean1.xml");
        IAccountService service1 = (IAccountService) applicationContext.getBean("IAccountService");
        service1.saveAccount();
        /*
        * 第二种 使用静态类工厂*/
        ApplicationContext applicationContext1=new ClassPathXmlApplicationContext("Bean.xml");
        IAccountService service=(IAccountService) applicationContext1.getBean("IAccoutnService2");
        /*第三种 使用实例工厂来创建其他类对象*/
        ApplicationContext applicationContext2=new ClassPathXmlApplicationContext("Bean.xml");
        IAccountService service2=(IAccountService) applicationContext2.getBean("IAccoutnService3");

    }
}
